package cn.kgc.vue.controller;

import cn.kgc.vue.common.ResponseResult;
import cn.kgc.vue.common.ResponseStatus;
import cn.kgc.vue.entity.Score;
import cn.kgc.vue.form.ScoreLsitForm;
import cn.kgc.vue.form.StudentLsitForm;
import cn.kgc.vue.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/***
 *@title ScoreController
 *@author 韩旭
 *@version 1.0.0
 *@create 2023/8/21 11:08
 **/
@RestController
@RequestMapping("score")
public class ScoreController {
    @Autowired
    private ScoreService scoreService;
    @GetMapping("getlist")
    public ResponseResult getlist(ScoreLsitForm scoreLsitForm){
        return scoreService.getlist(scoreLsitForm);
    }

    //修改和增加的功能
    @PostMapping("addOrupdate")
    public ResponseResult addorupdate(@RequestBody Score score){
        ResponseResult responseResult = new ResponseResult();
        scoreService.saveOrUpdate(score);
        responseResult.success();
        return responseResult;
    }

    //删除功能
    @DeleteMapping("delete")
    public ResponseResult delete(@RequestBody List<Integer> ids){
        ResponseResult responseResult = new ResponseResult();
        scoreService.removeBatchByIds(ids);
        responseResult.success(ResponseStatus.DELETE_SUCCESS);
        return responseResult;
    }

    @GetMapping("getscorelist")
    public ResponseResult getscorelist(){
        return scoreService.getscorelist();
    }

    @GetMapping("getscoretop")
    public ResponseResult getscoretop(){
        return scoreService.getscoretop();
    }
}
